#include "dac.h"

void DAC_Init(void)
{
    //配置PA4 PA5 DAC引脚
    rcu_periph_clock_enable(RCU_AF); //AF时钟使能
    rcu_periph_clock_enable(RCU_GPIOA);//GPIOA时钟使能
	rcu_periph_clock_enable(RCU_DAC);//DAC时钟使能
	gpio_init(GPIOA, GPIO_MODE_AIN, GPIO_OSPEED_50MHZ, GPIO_PIN_4 | GPIO_PIN_5);
    
    /* configure the DAC0 */
    dac_deinit();
    dac_trigger_disable(DAC0);
    dac_wave_mode_config(DAC0, DAC_WAVE_DISABLE);
    dac_output_buffer_enable(DAC0);
    
    /* configure the DAC1 */
    dac_trigger_disable(DAC1);
    dac_wave_mode_config(DAC1, DAC_WAVE_DISABLE);
    dac_output_buffer_enable(DAC1);
    
    /* enable DAC concurrent mode and set data */
    dac_concurrent_enable();
}
